package com.situ.crm.controller;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;

public class POITest {
	
	//写入excel表
	@Test
	public void testWrider07Excel() throws Exception {
		//1、创建工作簿：Workbook。
		XSSFWorkbook workbook = new XSSFWorkbook();
		//2、创建工作表：Sheet。
		XSSFSheet sheet = workbook.createSheet("Hello POI");
	    //3、创建行：Row。下标为0，第三行
		XSSFRow row = sheet.createRow(2);
		//4、创建单元格：Cell。下标为0，第三列
		XSSFCell cell = row.createCell(2);
		cell.setCellValue("Hello POI@@@");
		
		//输出excel到文件
		FileOutputStream outputStream = new FileOutputStream("D:\\poitest\\工作簿1.xlsx");
		workbook.write(outputStream);
		workbook.close();
		outputStream.close();
	}
}
